<html xmlns="http://www.w3.org/1999/xhtml" >
<%@ page language="java" import	="java.io.*,java.sql.*" %>

<%@include file="dbcon.jsp"%>
<%
	int iMsgId = 1; 
	int iSno = 0;
	int iRecType = 0;
			
	String sTmp = request.getParameter("hid_RecType");
	if ( sTmp != null && !sTmp.equals("null") && !sTmp.equals("") )
		iRecType = Integer.parseInt(sTmp);
	
	sTmp = request.getParameter("hid_RecSno");
	if ( sTmp != null && !sTmp.equals("null") && !sTmp.equals("") )
		iSno = Integer.parseInt(sTmp);
//System.out.println("iSno : "+ iSno);			
	if ( sTmp == null || sTmp.equals("null") || sTmp.equals("") )
	{
		response.sendRedirect("frm_make.jsp");
		//System.out.println("sTmp : "+ sTmp);				
		return;
	}
	
		String sMake = request.getParameter("txt_make");			
	try{		
		String sRtnMsg = "";
		if ( iRecType == 1 )
		{
			String sQry = "insert into tbl_make_master(makename,status) values('"+ sMake +"',1)";
		System.out.println("tbl_make_master Qry : "+ sQry);					
		//System.out.println("tbl_category_master Qry : "+ sQry);							
			Statement Stmt = Con.createStatement();
			Stmt.executeUpdate(sQry);
			if ( Stmt != null ) Stmt.close();

			iMsgId = 1;
			System.out.println("Insert Successfully");
			//System.out.println("Insert Successfully");
		}
		else if ( iRecType == 2)
		{
			String sQry = "update tbl_make_master set makename='"+ sMake +"'";
			sQry += " where makeid="+ iSno;
		System.out.println("tbl_make_master Qry : "+ sQry);					
		//System.out.println("tbl_category_master Qry : "+ sQry);					
			/*Statement Stmt = Con.createStatement();
			Stmt.executeUpdate(sQry);
			if ( Stmt != null ) Stmt.close();*/
			
			Statement Stmt = Con.createStatement();
			Stmt.executeUpdate(sQry);
			if ( Stmt != null ) Stmt.close();
					
			iMsgId = 3;
			System.out.println("Update Successfully");
			//System.out.println("Insert Successfully");
		}
	}
	catch(Exception e)
	{	
		System.out.println("Failed : "+ e);	
		if ( iRecType == 1 ) iMsgId = 2;
		else iMsgId = 4;
	}
	
	if ( Con != null ) Con.close();
	response.sendRedirect("frm_msg.jsp?MsgID="+ iMsgId);
	//System.out.println("Insert Failed");
%>
</html>